package com.cspm.gen.enums;

/**
 * 数据类型对照表
 */
public enum MysqlDataTypeEnum {

    TINYINT("tinyint", "Integer" ),
    SMALLINT("smallint", "Integer" ),
    MEDIUMINT("mediumint", "Integer" ),
    INT("int", "Integer" ),
    INTEGER("integer", "Integer" ),
    BIGINT("bigint", "Long" ),
    FLOAT("float", "Float" ),
    DOUBLE("double", "Double" ),
    DECIMAL("decimal", "BigDecimal" ),
    CHAR("char", "String" ),
    VARCHAR("varchar", "String" ),
    TINYTEXT("tinytext", "String" ),
    TEXT("text", "String" ),
    MEDIUMTEXT("mediumtext", "String" ),
    LONGTEXT("longtext", "String" ),
    DATA("date", "Date" ),
    TIME("time", "Date" ),
    DATATIME("datetime", "Date" ),
    TIMESTAMP("timestamp", "Date" );

    //数据库字段类型
    private String dataType;
    //JAVA对象类型
    private String javaType;

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getJavaType() {
        return javaType;
    }

    public void setJavaType(String javaType) {
        this.javaType = javaType;
    }

    MysqlDataTypeEnum(String dataType, String javaType) {
        this.dataType = dataType;
        this.javaType = javaType;
    }

    public static MysqlDataTypeEnum getDataType(String dataType) {
        for (MysqlDataTypeEnum e : MysqlDataTypeEnum.values()) {
            if (e.getDataType().equals(dataType)) {
                return e;
            }
        }
        return null;
    }
}